package cac.fenjian.resource.ReturnApplyQuery.service;

import cac.fenjian.resource.ReturnApplyQuery.dao.ReturnApplyQueryDao;
import cac.fenjian.resource.WmsReturnApply.dto.WmsReturnApplyDTO;
import com.cac.dme.adapter.rest.msg.QueryReqBean;
import com.cac.dme.adapter.rest.msg.QueryRespBean;
import com.cac.dme.adapter.utils.PageHelper;
import com.cac.dme.common.exception.service.DaoException;
import com.github.pagehelper.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;

@Service
public class ReturnApplyService {
    @Autowired
    private ReturnApplyQueryDao returnApplyQueryDao;

    @Transactional
    //退货页面条件查询
    public QueryRespBean<WmsReturnApplyDTO> ReturnApplyQuery(QueryReqBean<WmsReturnApplyDTO> queryReqBean, String orderBy, String Keywords, Date startTime, Date endTime
    ) {
        QueryRespBean<WmsReturnApplyDTO> queryRespBean =new QueryRespBean<>();
        try {
            PageHelper.startPage(queryReqBean.getPageParameter());
            WmsReturnApplyDTO searchParams = queryReqBean.getSearchParams();
            Page<WmsReturnApplyDTO> dataList = returnApplyQueryDao.ReturnApplyQuery(searchParams,orderBy,Keywords,startTime,endTime);
            queryRespBean.setResult(dataList);
            return queryRespBean;
        }catch (Exception e) {
            throw new DaoException(e.getMessage(), e);
        }
    }
    //验证查询是否为空
    @Transactional
    public List<WmsReturnApplyDTO> ReturnApplyQuery1(WmsReturnApplyDTO searchParams, String Keywords, Date startTime, Date endTime){
        List<WmsReturnApplyDTO> dataList = returnApplyQueryDao.ReturnApplyQuery(searchParams, Keywords, startTime, endTime);
        return dataList;
    }

}
